1. Field of the Invention
The invention relates to video or audio decoding, and more particularly to a variable length decoding (VLD).
2. Description of the Related Art
Variable length coding (VLC) is a multimedia file coding technique, which can reduce a great quantity of coded data, so that a data transmission bandwidth or a storing space will also be reduced. VLC is widely applied in various video or audio coding formats, such as motion picture experts group (MPEG) coding. Moreover, the coded data is decoded through VLD to be recovered as an original code when the coded data is playing.
FIG. 1A shows a block diagram of an MPEG coder 100. The MPEG coder 100 comprises a motion estimation module 102, a discrete cosine transformation (DCT) module 104, a quantization module 106 and a VLC module 108. First, the motion estimation module 102 compares an input image and a reference image to obtain an image difference. Next, the DCT module 104 transforms the image difference into a DCT value. After the DCT value is quantized by the quantization module 106, a VLC operation is performing by the VLC module 108 to obtain a coded data.
FIG. 1B shows a block diagram of an MPEG decoder 150. The MPEG decoder 150 comprises a VLD module 152, an inverse quantization module 154, an inverse discrete cosine transformation (IDCT) module 156 and a motion compensation module 158. First, the VLD module 152 decodes the coded data to a decoded data through a VLD operation, and then the decoded data is inverse-quantized to the DCT value by the inverse quantization module 154. Next, the IDCT module 156 transforms and recovers the DCT value to the image difference. Finally, the motion compensation module 158 compensates an image by the image difference to obtain an output image.
However, the VLD module 152 shown in FIG. 1B requires much time to output a serial of zero values as the decoded data during decoding. Statistically, the serial of zero values will account for 70%-98% of the decoded data output from the VLD module 152.
The serial of zero values are output at least during the following statuses: 1) when an end of block (EOB) data is read; 2) when a coded block pattern (CPB) bit is zero; 3) when a skipped macro block data is read; and 4) when a run-level pair of the coded data is decoded. FIG. 2A shows a data block 200 with an EOB code 202. The decoded data decoded by the VLD module 152 comprises 8×8 (64) data which are composed of a serial of data blocks.
In the data block 200 of the decoded data output from the VLD module 152, the data values (shown as label 204) appearing after a pixel 202 are zero, wherein a value of the pixel 202 is 5, when the VLD module 152 reads an EOB code from a received coded data, such as the pixel 202 shown in FIG. 2A, which is interpreted as 5, and then a 2 bit EOB code “10” is met. The EOB code is not shown in FIG. 2A due to the fact that an EOB code only exists in the coded data and can not be decoded.
Furthermore, each macro block is composed of six data blocks among the decoded data. The macro block comprises four Y data blocks and Cb and Cr data blocks sampled from the four Y data blocks, wherein the four Y data blocks are shown as label 212 in FIG. 2B. The coded data read by the VLD module 152 comprises a CBP bit for indication of the data blocks which values are zero within a macro block. Thus, the VLD module 152 will output a data block which has zero values when the VLD module 152 reads that a CBP bit of a data block 214 of the coded data is zero. In addition, the skipped macro block data represents that all values of six data blocks composing a macro block are zero, shown as six data blocks 223-228 of a macro block 222 in FIG. 2C. Therefore, total capacity of six data blocks are output as zero values when the CBP bit is read by the VLD module 152.
FIG. 2D shows a process wherein a data block 232 is coded as a serial of run-level pairs through a VLC technique. A run-level pair comprises a run value and a level value. For example, the data block 232 comprises a serial data “1005000008”, wherein 8 is a last level value. The serial data is coded as 1, (2, 5) and (5, 8), wherein (2, 5) and (5, 8) are run-level pairs. Thus, the VLD module 152 will output a lot of zero values according to the run value of each run-level pair when the run-level pair of the coded data is decoded.
If continuous zero values are output, a decoding time will be delayed and total decoding performance of the MPEG decoder 150 will be reduced. Thus, by improving the above disadvantages VLD efficiency can be enhanced and performance of video and audio decoding can be substantially increased.